package lesson2;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.Test;

import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import static com.thoughtworks.selenium.SeleneseTestCase.assertEquals;
import static junit.framework.Assert.assertTrue;

/**
 * Created by Worker31 on 19.03.14.
 */
public class Homework3 {

    @Test
    public void test() throws Exception {
        WebDriver driver = new FirefoxDriver();
        StringBuffer verificationErrors = new StringBuffer();
        String baseUrl = "http://www.ukr.net/";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.get(baseUrl);
        driver.findElement(By.linkText("ROZETKA")).click();

        for(String winHandle : driver.getWindowHandles()){
            driver.switchTo().window(winHandle);
        }

       driver.findElement(By.xpath("//*[@id='body-header']/div[1]/div/div/div[1]/a")).click();


        try {
            assertEquals(true, driver.findElement(By.id("user_header")));
        } catch (Error e) {
            verificationErrors.append(e.toString());
        }

        driver.quit();
}
}
